<script setup lang="ts">

import {ref} from "vue";
import {useRoute} from "vue-router";
import router from "@/router";


const data = ref({});

const route=useRoute(); //获取路由信息
const getValue=()=>{
  if (route.query.params){
    data.value=JSON.parse(route.query.params).data;
    // console.log(data.value)
    // console.log("系统页面接收："+data.value);
  }else{
    console.log("系统页面，没有接收到params")
  }
}
getValue()

const Data=ref([
  {
    avatar:'https://s21.ax1x.com/2025/05/09/pEO1HRx.jpg',
    username:data.value.username,
    password:data.value.password,
    phone:data.value.phone,
    email:data.value.email,
    systemTitle:'超级管理员系统',
    type:'superAdmin',
    list:{
      listText:["数据大屏","公告列表","投诉管理","订单数据","管理员审核","管理员管理","商家审核",'商家管理','顾客管理','账号管理'],
      routerPth:["/dataView","/announcement","/complaint","/orderData","/adminReview","/adminManagement","/sellerReview","/business","/customerManagement","/adminSelf"],
    },
  },
  {
    avatar:'https://s21.ax1x.com/2025/05/09/pEO1LQK.png',
    username:data.value.username,
    password:data.value.password,
    phone:data.value.phone,
    email:data.value.email,
    systemTitle:'管理员系统',
    type:'admin',
    list:{
      listText:["数据大屏","公告列表","投诉管理","订单数据","商家审核",'商家管理','顾客管理','账号管理'],
      routerPth:["/dataView","/announcement","/complaint","/orderData","/sellerReview","/business","/customerManagement","/adminSelf"],
    },
  },
  {
    avatar:'https://s21.ax1x.com/2025/05/13/pEX52xs.png',
    username:data.value.username,
    password:data.value.password,
    phone:data.value.phone,
    email:data.value.email,
    systemTitle:'商家系统',
    type:'seller',
    list:{
      listText:['我的店铺',"商品管理","客户管理",'订单中心','账号管理'],
      routerPth:["/myShop","/product","/customer","/orderCenter","/sellerSelf"],
    },
  },
  {
    avatar:'https://s21.ax1x.com/2025/05/13/pEX5WMn.png',
    username:data.value.username,
    password:data.value.password,
    phone:data.value.phone,
    email:data.value.email,
    systemTitle: '',
    type:'buyer',
    list:{
      listText:["店铺列表","购物车",'我的订单','账号管理'],
      routerPth:["/shops","/shoppingCart","/myOrder","/buyerSelf"],
    },
  },
])
// const type="admin"; // 可选：admin,seller,buyer
switch (data.value.type){
  case "superAdmin":
    data.value=Data.value[0];
    break;
  case "admin":
     data.value=Data.value[1];
    break;
  case "seller":
    data.value=Data.value[2];
    break;
  case "buyer":
    data.value=Data.value[3];
    break;
  default:
    alert("当前身份模糊！");
    break;
}
// console.log(data)
</script>

<template>
  <main>
    <div class="main">
      <div class="nav">
        <div class="icon">

        </div>
        <div class="title">
          <p>鲜花交易中心</p>
          <p>{{data.systemTitle}}</p>
        </div>

        <div class="userInfo">
          <div class="userImg" :style="{backgroundImage:'url('+data.avatar+')'}"></div>
          <router-link to="/">退出</router-link>
        </div>
      </div>
      <div class="content">
        <div class="side">
            <div class="sideUserImg" :style="{backgroundImage:'url('+data.avatar+')'}"></div>
            <div class="sideUserName">{{data.username}}</div>
            <ul>
              <li v-for="(item,index) in data.list.listText">
                <router-link :to="data.list.routerPth[index]">{{item}}</router-link>
              </li>
            </ul>

        </div>
        <div class="mainContent">
          <RouterView></RouterView>
        </div>
      </div>
    </div>
  </main>
</template>

<style scoped>
*{
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
main{
  width: 100vw;
  height: 100vh;
  position: relative;
}
.main{
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: white;
  .nav{
    position: relative;
    width: 100%;
    height: 10%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 0 10px 5px gray;
    background-color: rgb(50, 108, 55);
    color: white;
    .icon{
      width: 70px;
      height: 70px;
      background-image: url("../assets/images/index5.png");
      background-repeat: no-repeat;
      background-size: cover;
      background-position: center;
    }
    .title{
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      p{
        font-size: 35px;
        font-weight: 200;
      }
      p:nth-child(2){
        font-size: 20px;
      }
    }
    .userInfo{
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      .userImg{
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background-repeat: no-repeat;
        background-size: cover;
      }
      a{
        color: white;
        text-decoration: none;
        font-size: 20px;
        user-select: none;
        cursor: pointer;
      }
    }
  }
  .content{
    width: 100%;
    height: 90%;
    display: flex;
    flex-direction: row;
    //gap: 15px;
    .side{
      z-index: 1;
      width: 15%;
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 20px;
      gap: 20px;
      box-shadow: 0 15px 10px 5px gray;
      background-color: rgb(46, 135, 54);
        .sideUserImg{
          width: 100px;
          height: 100px;
          border-radius: 50%;
          background-repeat: no-repeat;
          background-size: cover;
        }
        .sideUserName{
          text-align: center;
          color: white;
          font-size: 20px;
        }
        ul{
          width: 100%;
          list-style: none;
          font-size: 20px;
          text-align: center;
          background-color: white;
          border-radius: 20px;
          margin: 10px 0;
          border: solid 3px white;
          user-select: none;
          li{
            overflow: hidden;
            a{
              color: rgb(50, 108, 55);
              text-decoration: none;
              width: 100%;
              display: block;
            }
          }
          li:hover{
            cursor: pointer;
            background-color: rgb(50, 108, 55);
            font-weight: 200;
            a{
              color: white;
            }
          }
          li:nth-child(1):hover{
            border-radius: 20px 20px 0 0;
          }
          li:nth-last-child(1):hover{
            border-radius: 0 0 20px 20px;
          }
        }
    }
    .mainContent{
      width: 85%;
      height: 100%;
      padding: 20px;
    }
  }
}
</style>